package org.zhu.mybatis_test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zhu.mybatis_test.bean.Pageable;
import org.zhu.mybatis_test.bean.User;
import org.zhu.mybatis_test.bean.UserPage;

import java.awt.*;
import java.util.List;

/**
 * @author yingzhi zhu
 * date 2018/1/19.
 */
@RestController
public class TestController {

    @Autowired
    private TestMapper testMapper;


    @GetMapping("/page")
    public Object getPage(Pageable pageable) {
        return pageable.setContentAndReturn(testMapper.selectPage1(pageable, "peter", 5));
    }

    @GetMapping("/page1")
    public Object getPage1(Pageable pageable) {
        return pageable.setContentAndReturn(testMapper.selectPage(pageable));
    }

    @GetMapping("/page2")
    public Object getPage2(UserPage userPage) {
        return userPage.setContentAndReturn(testMapper.selectPage2(userPage));
    }

    @GetMapping("/no_page")
    public Object getIndex() {
        return testMapper.getAll();
    }

    @GetMapping("/update")
    public Object updateUser() {
        return testMapper.updateUser();
    }
}
